using System;
using System.Collections.Generic;
using System.Windows;
using Microsoft.Phone.Shell;
using WindowsPhoneEssentials.Abstractions;

namespace WindowsPhoneEssentials.Testing.Abstractions
{
    public class FakePhoneApplicationService : IPhoneApplicationService
    {
        private readonly IDictionary<string, object> stateDictionary = new Dictionary<string, object>();

        public void StartService(ApplicationServiceContext context)
        {
            
        }

        public void StopService()
        {
        }

        public IdleDetectionMode UserIdleDetectionMode { get; set; }

        public IdleDetectionMode ApplicationIdleDetectionMode { get; set; }

        public IDictionary<string, object> State
        {
            get { return stateDictionary; }
        }

        public StartupMode StartupMode { get; set; }

        public event EventHandler<LaunchingEventArgs> Launching;
        public event EventHandler<ActivatedEventArgs> Activated;
        public event EventHandler<DeactivatedEventArgs> Deactivated;
        public event EventHandler<ClosingEventArgs> Closing;

        public void OnActivated(ActivatedEventArgs e)
        {
            var handler = Activated;
            if (handler != null) handler(this, e);
        }

        public void OnDeactivated(DeactivatedEventArgs e)
        {
            var handler = Deactivated;
            if (handler != null) handler(this, e);
        }

        public void OnLaunching(LaunchingEventArgs e)
        {
            var handler = Launching;
            if (handler != null) handler(this, e);
        }

        public void OnClosing(ClosingEventArgs e)
        {
            var handler = Closing;
            if (handler != null) handler(this, e);
        }
    }
}